package com.neusoft.controller;

import com.neusoft.pojo.User;
import com.neusoft.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
/**
 * @author 新
 * 有关订单的controller层
 */
@Controller
public class OrderController {
	
	@Autowired
	private OrdersService ordersService;
	
	/**
	 * @param ocost 总金额
	 * @return 重定向至购物车列表页
	 */
	@RequestMapping("balance")
	public String balance(Integer ocost,HttpSession session) {
		//获取用户信息
		User user = (User) session.getAttribute("user");
		//调用ordersService的addOrders的方法添加一条新的订单
		ordersService.addOrders(user.getUid(), ocost, user.getUname());
		return "redirect:showCartList";
	}
}
